package com.weng.cloud.starter.batch.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.ItemWriteListener;

import java.util.List;

/**
 * @Author: weng
 * @Date: 2022/3/20
 * @Description: com.weng.cloud.starter.batch.listener
 */
public class LogItemWriteListener<T> implements ItemWriteListener<T> {

    @Override
    public void beforeWrite(List<? extends T> list) {
        System.out.println("批量写入开始,行数:"+list.size());
    }

    @Override
    public void afterWrite(List<? extends T> list) {
        System.out.println("批写入完成,行数:"+list.size());
    }

    @Override
    public void onWriteError(Exception e, List<? extends T> list) {
        System.err.println("批量写入异常 "+e.getMessage());
    }
}
